<?php
include $_SERVER['DOCUMENT_ROOT'].'/PariGest/pages/inc/enteteAjax.php';
require_once $REP_CLASS . 'class.Compte.php';
$compte = new Compte($db);
try
{
    if( $_POST["Action"] == "Add" )
    {
    	$compte->setLibelle($_POST["Libelle"]);
    	$compte->setDefaut($_POST["Defaut"]);
    	$compte->setSolde($_POST["Solde"]);
    	$compte->setDateMaj($_POST["DateMaj"]);
    	//$compte->setSoldeVirtuel($_POST["SoldeVirtuel"]);
    	$compte->setCommentaire($_POST["Commentaire"]);
    	$idCompte = $compte->insertion();
    	$smarty->assign('ligne', $compte->select()->fetch());
    	$smarty->display('inc/IncCompte.tpl');     
    }
    elseif( $_POST["Action"] == "Del" )
    {
    	$idCompte = $_POST["idCompte"];
    	$compte->setIdCompte($idCompte);
    	$compte->suppression();
    	//throw new Exception("jhgfjhg");
    }
    $db->commit();
}
catch(MyException $e)
{
  include $_SERVER['DOCUMENT_ROOT'].'/PariGest/pages/inc/catchAjax.php';      
}
	
?>